%%%-------------------------------------------------------------------
%%% @author Administrator
%%% @copyright (C) 2020, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 06. 3月 2020 13:25
%%%-------------------------------------------------------------------
-module(player_util).
-author("Administrator").

-include("../include/myshare.hrl").
-include("../include/player.hrl").
-include("../include/logger.hrl").
%% API
-compile(export_all).
-compile(nowarn_export_all).

p()->
  players().

state(Account)->
  get_player_state(Account).

players() ->
  Players = ets:tab2list(?ETS_PLAYER_INFO),
  io:format("players :~p ~n", [Players]).

get_player_state(Account) ->
  case ets:lookup(?ETS_PLAYER_INFO, Account) of
    [] -> io:format("not this player ~n");
    [Player] ->
      PlayerState = gen_server:call(Player#player_info.pid, {player_state}),
      io:format("player state :~p ~n",[PlayerState]),
      GamePid = PlayerState#player_state.game_pid,
      case is_pid(GamePid) of
        true ->
          GameState = gen_server:call(GamePid, get_state),
          io:format("game_state :~p ~n", [GameState]),
          GameState;
        _->
          io:format("game is not run")
      end
  end.

test()->
  State = get_player_state("86-9999025"),
  Score = game_assist:get_Into_integral(State),
  ?DEBUG("cccccc:~p",[Score]).




